var user = {};
user.bonus = {};
user.order = {};

user.init = function(){
    $(document).ready(function(){
        user.order.consignee();
    });
};
user.init();

//处理bonus_sn
function add(id){
    if($('input[name="bonus_sn"]').val==""){
        alert("必须输入优惠券号码");
        return false;
    }else{
        return true;
    }
};
function addBonus()
{
    var frm      = document.forms['addBouns'];
    var bonus_sn = frm.elements['bonus_sn'].value;

    if (bonus_sn.length == 0)
    {
        alert("必须输入优惠券号码");
        return false;
    }
    /*
     else
     {
     var reg = /^[0-9]{10}$/;
     if ( ! reg.test(bonus_sn))
     {
     alert(bonus_sn_error);
     return false;
     }
     }
     */

    return true;
}

user.order.consignee = function(){
    $('#modify-consignee').click(function(){
        $.ajax({
            type: "GET",
            url: "userorderaddress.php?t="+ new Date().getTime(),
            dataType: "json",
            data: "act=show_order_address&order_id="+ $(this).siblings('input[name="order_id"]').val() +"&province="+ $(this).siblings('input[name="province"]').val() +"&city="+ $(this).siblings('input[name="city"]').val(),
            success: function(data){
                if(data.error){
                    $("#dialog-modal").html(data.msg).dialog();
                } else {
                    $("#dialog-modal").html(data.data.html).dialog({
                        width: 512,height:360,
                        modal:true,
                        focus:function(ev,data){$('#addOk').focus();}
                    });
                    $('#dialog-modal').on('click','#addBack',function(){
                        $("#dialog-modal").dialog("close");
                    });
                }
            }
        });
    });
};